package HomeWork;
/*   6.
 *   "java woaijava,i like jajavava,i enjoy java"
 *   "java"
 *   把java的内容删除后为
 *   "woai,i like,i enjoy"
 */
public class work06 {
    public static void main(String[] args) {
        String str="java woaijava,i like jajavava,i enjoy java";
        String shanchu="java";
        String result = removeSubstring(str, shanchu);
        System.out.println(result);
    }

    public static String removeSubstring(String str, String substr) {
        if (str == null || substr == null || substr.isEmpty()) {
            return str;
        }

        int index = 0;
        while ((index = str.indexOf(substr, index)) != -1) {
            str = str.substring(0, index) + str.substring(index + substr.length());
        }

        return str;
    }
}
